﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZhCun.Framework.Common;
using ZhCun.Framework.DataAccess.BLL;
using ZhCun.Framework.DataAccess;
using ZhCun.Framework.WinTest.Models;
using ZhCun.Framework.Common.Models.TableModel;

namespace ZhCun.Framework.WinTest
{
    public class BLLCommon : BLLBase
    {
        static string ConnStr
        {
            get
            {
                // "Data Source=192.168.0.55;Initial Catalog=aa;uid=sa;pwd=sunway";
                return Configurations.GetConnectString("Test");
            }
        }
        public BLLCommon()
            : base(DatabaseTypeEnum.SQLServer, ConnStr)
        {
            InsertBeforeHandle += new DataAccess.DataDelegate.BLLModelHandle(BLLCommon_InsertBeforeHandle);
        }

        public override int Add<TModel>(params TModel[] models)
        {
            foreach (var item in models)
            {
                Test1 m = item as Test1;
                if (m != null)
                {
                    m.Remark = "aa";
                }
            }
            return base.Add<TModel>(models);
        }

        void BLLCommon_InsertBeforeHandle(params Common.Models.TableModel.ModelBase[] models)
        {
            if (models == null) return;
            foreach (var item in models)
            {
                Test1Insert(item);
            }
        }
        void Test1Insert(ModelBase model)
        {
            Test1 t = model as Test1;
            if (t == null) return;
            t.Remark = "InsertBeforeHandle";
        }
    }
    class TestGuiZe1
    {
        public TestGuiZe1(ModelBase model)
        {
            _Test1Model = model;
        }
        ModelBase _Test1Model;

        public void InsertGuiZe()
        {

        }
    }
}
